package com.nav.backend.mapper;

import com.nav.backend.pojo.CollectionLocation;
import com.nav.backend.pojo.CollectionPath;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * CollectionMapper 接口用于定义和收藏相关的数据库操作
 *
 * @author xiukira
 */
@Mapper
public interface CollectionMapper {

    /**
     * 获取收藏路径列表
     *
     * @param account String 账户名
     * @return 收藏路径列表 List<CollectionPath>
     */
    @Select("select * from collection_path where account = #{account}")
    List<CollectionPath> pathListAll(String account);

    /**
     * 删除收藏路径
     *
     * @param collectionPathId Integer 收藏路径id
     */
    @Delete("delete from collection_path where collection_path_id = #{collectionPathId}")
    void pathDelete(Integer collectionPathId);

    /**
     * 收藏路径
     *
     * @param collectionPathOrigin       String 收藏路径起点
     * @param collectionPathOriginX      Double 收藏路径起点经度
     * @param collectionPathOriginY      Double 收藏路径起点纬度
     * @param collectionPathDestination  String 收藏路径终点
     * @param collectionPathDestinationX Double 收藏路径终点经度
     * @param collectionPathDestinationY Double 收藏路径终点纬度
     * @param collectionPathInfo         String 收藏路径信息
     * @param distance                   Double 收藏路径路程
     * @param time                       Double 收藏路径时长
     * @param treeLine                   Double 收藏路径林荫道占比
     * @param mark                       integer 收藏路径评分
     * @param account                    String 账户名
     */
    @Insert("insert into collection_path(collection_path_origin,collection_path_origin_x," +
            "collection_path_origin_y,collection_path_destination," +
            "collection_path_destination_x,collection_path_destination_y," +
            "collection_path_info,distance,time,tree_line,mark,account) " +
            "values (#{collectionPathOrigin},#{collectionPathOriginX}," +
            "#{collectionPathOriginY},#{collectionPathDestination}," +
            "#{collectionPathDestinationX},#{collectionPathDestinationY}," +
            "#{collectionPathInfo},#{distance},#{time},#{treeLine}," +
            "#{mark},#{account})")
    void pathAdd(String collectionPathOrigin, Double collectionPathOriginX, Double collectionPathOriginY, String collectionPathDestination, Double collectionPathDestinationX, Double collectionPathDestinationY, String collectionPathInfo, Double distance, Double time, Double treeLine, Integer mark, String account);

    /**
     * 收藏地点
     *
     * @param collectionLocation     String 收藏地点
     * @param collectionLocationX    Double 地点经度
     * @param collectionLocationY    Double 地点纬度
     * @param collectionLocationInfo String 地点信息
     * @param account                String 账户名
     */
    @Insert("insert into collection_location(collection_location,collection_location_x,collection_location_y," +
            "collection_location_info,account) values(#{collectionLocation},#{collectionLocationX},#{collectionLocationY},#{collectionLocationInfo},#{account})")
    void poiAdd(String collectionLocation, double collectionLocationX, double collectionLocationY, String collectionLocationInfo, String account);

    /**
     * 获取收藏地点列表
     *
     * @param account String 账户名
     * @return 收藏地点列表 List<CollectionLocation>
     */
    @Select("select * from collection_location where account = #{account}")
    List<CollectionLocation> poiListAll(String account);

    /**
     * 删除收藏地点
     *
     * @param collectionLocationId Integer 收藏地点id
     */
    @Delete("delete from collection_location where collection_location_id = #{collectionLocationId}")
    void poiDelete(int collectionLocationId);
}
